package 滑动;

public class _1343大小为K且平均值大于等于阈值的子数组数目 {

    public static int numOfSubarrays(int[] arr, int k, int threshold) {
        int r =0;
        int len = arr.length;
        int temp=0;
        int line=k*threshold;

        for (int i = 0; i < len; i++) {
            temp+=arr[i];
            if(i<k-1){
                continue;
            }
            if(temp>=line){
                r++;
            }
            temp-=arr[i-k+1];
        }
        return r;


    }

    public static void main(String[] args) {
        System.out.println("result::::"+numOfSubarrays(new int[]{2,2,2,2,5,5,5,8}, 3, 4));
    }
}
